function goToUrl(url, newWindow){
    if (newWindow == null){
        newWindow = false;
    }
    if (newWindow == true) {
        window.open(url);
    }
    else{
        window.location.href = url;
    }
}

function AjaxSender(urlStr, methodStr, successFun, errorFun, jsonData) {
    $.ajax({
        url: urlStr,
        type: methodStr,
        data: jsonData,
        error: errorFun,
        success: successFun,
        dataType: 'json'
    });
}

function EzAjaxGet(url, success, failed) {
    failed = failed || function (data) {
        console.log(data);
    };
    AjaxSender(url, "get", success, failed);
}

function EzAjaxPut(url, json_param, success, failed) {
    failed = failed || function (data) {
        console.log(data);
    };
    AjaxSender(url, "put", success, failed, json_param);
}

function EzAjaxPost(url, json_param, success, failed) {
    failed = failed || function (data) {
        console.log(data);
    };
    AjaxSender(url, "post", success, failed, json_param);
}

function EzAjaxDelete(url, json_param, success, failed) {
    failed = failed || function (data) {
        console.log(data);
    };
    AjaxSender(url, "delete", success, failed, json_param);
}

function isNone(obj){
    return obj == "" || obj==null || obj==undefined || obj=={};
}

function getUrlParam(name) {
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  decodeURI(r[2]); return null;
}
